import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';






class SearchModule{

  late final VoidCallback voidCallbackEnter;

  //确认弹窗
  static confirmDialog(BuildContext context,voidCallbackEnter) {
    showDialog(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: const Text("温馨提示"),
          content: const Text("您确定要删除吗？"),
          actions: <Widget>[
            TextButton(
              onPressed: () {
                Navigator.of(context).pop();
              },
              child: const Text("取消"),
            ),
            TextButton(
              child: const Text("确定"),
              onPressed: () async {
                voidCallbackEnter();
              },
            ),
          ],
        );
      },
    );
  }

 static void closeKeyboard(BuildContext context) {
    FocusScopeNode currentFocus = FocusScope.of(context);
    /// 键盘是否是弹起状态
    if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
      FocusManager.instance.primaryFocus!.unfocus();
    }
  }

 /// 计算时间间隔(天)
 static timeInterval(var startDate,var endDate){
   // var startDate = new DateTime(2020, 12, 20);
   // var endDate = new DateTime.now();
   var days = endDate.difference(startDate).inDays;
   return days;
 }

 /// 计算时间间隔(小时)
 static timeIntervalHour(var startDate,var endDate){
   // var startDate = new DateTime(2020, 12, 20);
   // var endDate = new DateTime.now();
   var hour = endDate.difference(startDate).inMinutes;
   print(hour);
   return hour;
 }

 //确认弹窗

}
